$(function () {
    //获取url
    var url = localStorage.getItem("ajaxUrl");
    var work_id = "";
    var machine = localStorage.getItem("heatMachine");
    var work = "";
    var controlvalue_I = 2.800; //T
    var controlvalue_J = 0.500; //T
    var pass = 1;
    var focus = true;
    var qualityJson = {
        zj: "",
        bmzl: ""
    };

    $(".head .icon-lishi1").on("click", function () {
        var machine = $("section span.machine").html();
        if (machine != "空") {
            localStorage.setItem("heatMachine", machine);
        }
        window.location.href = "heat_lishi.html";
    });

    //搜索框 获取焦点
    $("#goods_id").focus();
    $("#goods_id").blur(function () {
        if (focus) {
            $("#goods_id").focus();
        }
    });

    $("div.page").on("click", "span.personal", function() {
        localStorage.removeItem("heatMachine");
        focus = false;
        $("#goods_id").blur();
    });

    $(".panel-overlay").on("click", function () {
        focus = true;
        setTimeout(function () {
            $("#goods_id").val("").focus();
        }, 1000);
    });

    //根据 id 得到 工单信息、机台信息
    getWorkFun(machine);

    function getWorkFun(machine) {
        if (machine) {
            loading_show("获取中...");
            $.ajax({
                headers: {authorization: "Bearer " + localStorage.getItem("jwt")},
                type: "post",
                url: url + '/app/heat/getHeatPlanAndMaterialByMachine',
                data: {
                    machine: machine
                },
                dataType: 'json',
                json: 'callback',
                success: function (res) {
                    loading_hide();
                    if (res.success) {
                        showplandata(res, machine)
                    } else {
                        console.log(res);
                        $alert(res.message);
                    }
                },
                error: function (error) {
                    loading_hide();
                    console.log(error);
                    $alert(error.responseText);
                }
            });
        } else {
            $("section span.machine").html("空");
        }
    }

    $("#goods_id").on("keydown", function (event) {
        if (event.keyCode == "13") {
            if (pass == 0) {
                return
            }
            pass = 0;
            var val = $(this).val();
            $("#goods_id").val("");
            if (!val) {
                $alert("请扫描热处理机台！");
                pass = 1;
                setTimeout(function () {
                    $("#goods_id").val("").focus();
                }, 1400);
                return;
            } else {
                $.ajax({
                    headers: {authorization: "Bearer " + localStorage.getItem("jwt")},
                    type: "post",
                    url: url + '/app/heat/getHeatPlanAndMaterialByMachine',
                    data: {
                        machine: val
                    },
                    dataType: 'json',
                    json: 'callback',
                    success: function (res) {
                        pass = 1;
                        loading_hide();
                        if (res.success) {
                            $alert(val + "扫描成功");
                            showplandata(res, val);
                        } else {
                            console.log(res);
                            $alert(res.message);
                        }
                    },
                    error: function (error) {
                        pass = 1;
                        loading_hide();
                        console.log(error);
                        $alert(error.responseText);
                    }
                });
            }
        }
    });
    function showplandata(res, machine) {
        var data = res.result;
        work = data.plan;
        if (res.controlvalue) {
            if (res.controlvalue["I"]) {
                controlvalue_I = res.controlvalue["I"];
            }
            if (res.controlvalue["J"]) {
                controlvalue_J = res.controlvalue["J"];
            }
        }
        $("section span.machine").html(machine);
        if (data.plan && data.plan.workplanNumber) {
            work_id = data.plan._id;
            $("section span.workplanNumber").html(data.plan.workplanNumber);
            $("section span.kh").html(data.plan.customerName);
            $("section span.ddlx").html(data.plan.saleordertype);
            $("section span.work_mc").html(data.plan.inventoryName);
            $("section span.work_gg").html(data.plan.inventorySpecification);
            $("section span.work_djzl").html(data.plan.singleQuantity);
            $("section span.work_bzfs").html(data.plan.packMethod || "无");
            $("section span.work_klqd").html(data.plan.tensileStrength);
            $("section span.work_sll").html(data.plan.zincLayerWeight);
            $("section span.work_weight").html(data.plan.detail.planQuantity);
            $("section span.work_completeWeight").html(data.plan.detail.completeQuantity ? Number(parseFloat(data.plan.detail.completeQuantity).toFixed(3)) : "0");
        } else {
            $("section span.workplanNumber").html("空");
            $("section span.kh").html("空");
            $("section span.ddlx").html("空");
            $("section span.work_mc").html("空");
            $("section span.work_gg").html("空");
            $("section span.work_djzl").html("空");
            $("section span.work_bzfs").html("空");
            $("section span.work_klqd").html("空");
            $("section span.work_sll").html("空");
            $("section span.work_weight").html("空");
            $("section span.work_completeWeight").html("空");
        }
        if (data.material && data.material.length > 0) {
            $("section div.material span.number").html(data.material[0].batch);
            $("section div.material span.gggh").html(data.material[0].inventorySteel + " " + data.material[0].inventoryDiameter);
            $("section div.material span.lh").html(data.material[0].stove);
            $("section div.material span.column").html(data.material[0].column);
            $("section div.material span.weight").html(data.material[0].quantity);
            setAllmaterial(data.material);
            // if (Number(data.material[0].quantity) < 50) {
            //     $alert("当前原料剩余重量小于50KG了，请检查", 3000);
            // }
        } else {
            $("section div.material span.number").html("空");
            $("section div.material span.gggh").html("空");
            $("section div.material span.lh").html("空");
            $("section div.material span.column").html("空");
            $("section div.material span.weight").html("空");
            setAllmaterial([]);
        }
    }

    function setAllmaterial(material) {
        // console.log(material.length)
        var allMaterialHtml = "";
        for (var i = 1; i < material.length; i++) {
            allMaterialHtml += '  <div class="card-content-inner">' +
                '<p><span>编&#X3000;&#X3000;号 ：</span><span class="number">' + material[i].batch + '</span></p>' +
                '<p><span>规格钢号 ：</span><span class="gggh">' + material[i].inventorySteel + " " + material[i].inventoryDiameter + '</span></p>' +
                '<p><span>炉号 ：</span><span class="lh">' + material[i].stove + '</span>&nbsp;&nbsp;<span>卷号 ：</span><span class="column">' + material[i].column + '</span></p>' +
                '<p><span>剩余重量 ：</span><span class="quantity">' + material[i].quantity + '</span></p></div>'
        }
        $(".allMaterial").empty().html(allMaterialHtml).hide();
    }

    // 点击 下箭头
    $(".material").on("click", ".aaa", function (event) {
        var classname = $(this).attr("class");
        if (classname.indexOf("icon-xiashuangjiantou") > -1) {
            $(".allMaterial").show();
            $(this).removeClass("icon-xiashuangjiantou");
            $(this).addClass("icon-shangshuangjiantou");

        } else{
            $(".allMaterial").hide();
            $(this).removeClass("icon-shangshuangjiantou");
            $(this).addClass("icon-xiashuangjiantou");
        }
    });
    //点击 收线
    $(".bnt .shouxiao").on("click", function (event) {
        var workplanNumber = $("section span.workplanNumber").html();
        if (!workplanNumber || workplanNumber == "空") {
            return $alert("请先扫描机台号");
        }
        if ($("div.material span.number").html() && $("div.material span.number").html() != "空") {
            loading_show("获取中...");
            $.ajax({
                headers: {authorization: "Bearer " + localStorage.getItem("jwt")},
                type: "post",
                url: url + '/app/heat/getDataByMachine',
                dataType: 'json',
                data: {
                    id: work_id,
                    type: "收线",
                    machine: $("section span.machine").html()
                },
                json: 'callback',
                cache: false,
                timeout: 60000,
                success: function (res) {
                    if (res.success) {
                        var data = res.result;
                        loading_hide();
                        if (res.isTakeupTime) {
                            $.confirm("收线间隔时间过短，确认收线吗？", function () {
                                focus = false;
                                $(".mengceng").show();
                                $("div.div_shouxian").show();
                                $("div.div_shouxian select").val("合格").trigger("change");
                                $("div.div_shouxian input").val("");
                                $("div.div_shouxian input.cpzl").val(data.weight).focus();
                                $("div.div_shouxian input.cppz").val("0");
                            })
                        } else {
                            focus = false;
                            $(".mengceng").show();
                            $("div.div_shouxian").show();
                            $("div.div_shouxian select").val("合格").trigger("change");
                            $("div.div_shouxian input").val("");
                            $("div.div_shouxian input.cpzl").val(data.weight).focus();
                            $("div.div_shouxian input.cppz").val("0");
                        }
                    } else {
                        console.log(res);
                        $alert(res.message);
                    }
                },
                error: function (error) {
                    //隐藏提示符 显示
                    loading_hide();

                    if (error.status == 0) {
                        $alert("请求超时，请再试一次！");
                    } else {
                        console.log(error);
                        $alert(error.responseText);
                    }
                }
            });
        } else {
            $alert("请先上料！");
        }
    });

    //点击 收线 取消
    $(".sx_quxiao").click(function () {
        $(".mengceng").hide();
        $("div.div_shouxian").hide();
        $("#goods_id").val("").focus();
        focus = true;
    });
    //点击 收线 确定
    $(".sx_queding").click(function () {
        var zj = $("section span.work_gg").text().split(",")[0].replace(/m/ig, "");
        var zj_Min = Number(accSub(work.detail.inventoryDiameter, Math.abs(work.detail.diameterToleranceMin)));
        var zj_Max = Number(accAdd(work.detail.inventoryDiameter, Math.abs(work.detail.diameterToleranceMax)));
        var qualityInspectFrequency = work.detail.qualityInspectFrequency;
        console.log(zj_Max)
        console.log(zj_Min)
        console.log(qualityInspectFrequency)
        /*if (!$("div.div_shouxian #goods_cheng").val()) {
            pass = 1;
            $alert("请选择吊秤");
        } else */
        if (!$("div.div_shouxian input.actualDiameter").val()) {
            pass = 1;
            $alert("实测直径不可为空");
            $("div.div_shouxian input.actualDiameter").focus();
        }
        else if ($("div.div_shouxian input.actualDiameter").val() < 0) {
            pass = 1;
            $alert("实测直径不可小于0");
            $("div.div_shouxian input.actualDiameter").focus();
        }
        else if (Math.abs(accSub($("div.div_shouxian input.actualDiameter").val(), zj)) > 1) {
            pass = 1;
            $alert("实测直径误差过大");
            $("div.div_shouxian input.actualDiameter").focus();
        } else if (!$("div.div_shouxian input.cpzl").val()) {
            pass=1;
            $alert("毛重不可为空");
            $("div.div_shouxian input.cpzl").focus();
        } else if (Number($("div.div_shouxian input.cpzl").val()) <= 0) {
            pass=1;
            $alert("毛重不可小于0");
            $("div.div_shouxian input.cpzl").focus();
        }  else if (Number($("div.div_shouxian input.cpzl").val()) > 9999) {
            pass=1;
            $alert("毛重不可大于9999");
            $("div.div_shouxian input.cpzl").focus();
        } else if ($("div.div_shouxian input.cppz").val() < 0 ) {
            pass=1;
            $alert("请输入皮重");
            $("div.div_shouxian input.cpzl").focus();
        } else if (accSub($("div.div_shouxian input.cpzl").val(), $("div.div_shouxian input.cppz").val()) <= 0) {
            pass=1;
            $alert("毛重不可小于皮重");
            $("div.div_shouxian input.cpzl").focus();
        } else {
            if (Number($("div.div_shouxian input.actualDiameter").val()) > Number(zj_Max) || Number($("div.div_shouxian input.actualDiameter").val()) < Number(zj_Min)) {
                qualityJson.zj = "直径不合格";
            } else {
                qualityJson.zj = "";
            }
            if ($("div.div_shouxian .bmzl").val() == "不合格") {
                qualityJson.bmzl = "表面质量不合格";
            } else {
                qualityJson.bmzl = "";
            }
            var bhgx = [];
            for (var k in qualityJson) {
                if (qualityJson[k]) {
                    bhgx.push(qualityJson[k]);
                }
            }

            // var shouxianWeight = Number(setWeight(zj, $("div.div_shouxian input.cppz").val()));
            // var work_weight = $("section span.work_weight").html();
            // var work_completeWeight = accAdd(($("div.div_shouxian select.selfResult").val() == "合格" ? Number(shouxianWeight) : 0), $("section span.work_completeWeight").html());
            // var chazhi = accSub(work_completeWeight, work_weight);
            if (qualityInspectFrequency == "全检") {
                if (pass ==0){
                    return
                }
                pass=0;
                //调用 收线 接口
                loading_show("收线中...");
                $.ajax({
                    headers: {authorization: "Bearer " + localStorage.getItem("jwt")},
                    type: "post",
                    url: url + '/app/heat/heatTakeup',
                    data: {
                        _id: work_id,
                        machine: $("section span.machine").html(),
                        scale: $("div.div_shouxian #goods_cheng").val(),
                        weight: $("div.div_shouxian input.cpzl").val(),
                        tare_weight: $("div.div_shouxian input.cppz").val(),
                        actualDiameter: $("div.div_shouxian input.actualDiameter").val(),
                        bmzl: $("div.div_shouxian .bmzl").val(),
                        selfResult: $("div.div_shouxian .selfResult").val(),
                        bhgx: JSON.stringify(bhgx),
                        printAmount: 3,
                        check: true
                    },
                    dataType: 'json',
                    json: 'callback',
                    success: function (res) {
                        pass=1;
                        if (res.success) {
                            //console.log(data);
                            loading_hide();
                            $(".mengceng").hide();
                            $("div.div_shouxian").hide();
                            takeupsuccess(res.workOver);
                            takeupSendLims(res.result._id, true);
                            // 打印 热处理 收线 标签
                            if (res.result) {
                                takeupPrint("heatTakeup", res.result);
                                takeupPrint("heatTakeup", res.result);
                            }
                        } else {
                            console.log(res);
                            loading_hide();
                            $alert(res.message);
                        }
                    },
                    error: function (error) {
                        pass=1;
                        console.log(error);
                        loading_hide();
                        $alert(error.responseText);
                    }
                });
            } else if (qualityInspectFrequency == "免检") {
                if (pass ==0){
                    return
                }
                pass=0;
                //调用 收线 接口
                loading_show("收线中...");
                $.ajax({
                    headers: {authorization: "Bearer " + localStorage.getItem("jwt")},
                    type: "post",
                    url: url + '/app/heat/heatTakeup',
                    data: {
                        _id: work_id,
                        machine: $("section span.machine").html(),
                        scale: $("div.div_shouxian #goods_cheng").val(),
                        weight: $("div.div_shouxian input.cpzl").val(),
                        tare_weight: $("div.div_shouxian input.cppz").val(),
                        actualDiameter: $("div.div_shouxian input.actualDiameter").val(),
                        bmzl: $("div.div_shouxian .bmzl").val(),
                        selfResult: $("div.div_shouxian .selfResult").val(),
                        bhgx: JSON.stringify(bhgx),
                        printAmount: 1,
                        check: false
                    },
                    dataType: 'json',
                    json: 'callback',
                    success: function (res) {
                        pass=1;
                        if (res.success) {
                            //console.log(data);
                            loading_hide();
                            $(".mengceng").hide();
                            $("div.div_shouxian").hide();
                            takeupsuccess(res.workOver);
                            takeupSendLims(res.result._id, false);
                            // 打印 热处理 收线 标签
                            if (res.result) {
                                takeupPrint("heatTakeup", res.result);
                            }
                        } else {
                            console.log(res);
                            loading_hide();
                            $alert(res.message);
                        }
                    },
                    error: function (error) {
                        pass=1;
                        console.log(error);
                        loading_hide();
                        $alert(error.responseText);
                    }
                });
            } else {
                $.modal({
                    title:  '是否留样？',
                    buttons: [
                        {
                            text: '否',
                            onClick: function() {
                                if (pass ==0){
                                    return
                                }
                                pass=0;
                                //调用 收线 接口
                                loading_show("收线中...");
                                $.ajax({
                                    headers: {authorization: "Bearer " + localStorage.getItem("jwt")},
                                    type: "post",
                                    url: url + '/app/heat/heatTakeup',
                                    data: {
                                        _id: work_id,
                                        machine: $("section span.machine").html(),
                                        scale: $("div.div_shouxian #goods_cheng").val(),
                                        weight: $("div.div_shouxian input.cpzl").val(),
                                        tare_weight: $("div.div_shouxian input.cppz").val(),
                                        actualDiameter: $("div.div_shouxian input.actualDiameter").val(),
                                        bmzl: $("div.div_shouxian .bmzl").val(),
                                        selfResult: $("div.div_shouxian .selfResult").val(),
                                        bhgx: JSON.stringify(bhgx),
                                        printAmount: 2,
                                        check: false
                                    },
                                    dataType: 'json',
                                    json: 'callback',
                                    success: function (res) {
                                        pass=1;
                                        if (res.success) {
                                            //console.log(data);
                                            loading_hide();
                                            $(".mengceng").hide();
                                            $("div.div_shouxian").hide();
                                            takeupsuccess(res.workOver);
                                            takeupSendLims(res.result._id, false);
                                            // 打印 热处理 收线 标签
                                            if (res.result) {
                                                takeupPrint("heatTakeup", res.result);
                                            }
                                        } else {
                                            console.log(res);
                                            loading_hide();
                                            $alert(res.message);
                                        }
                                    },
                                    error: function (error) {
                                        pass=1;
                                        console.log(error);
                                        loading_hide();
                                        $alert(error.responseText);
                                    }
                                });
                            }
                        },{
                            text: '是',
                            onClick: function() {
                                if (pass ==0){
                                    return
                                }
                                pass=0;
                                //调用 收线 接口
                                loading_show("收线中...");
                                $.ajax({
                                    headers: {authorization: "Bearer " + localStorage.getItem("jwt")},
                                    type: "post",
                                    url: url + '/app/heat/heatTakeup',
                                    data: {
                                        _id: work_id,
                                        machine: $("section span.machine").html(),
                                        scale: $("div.div_shouxian #goods_cheng").val(),
                                        weight: $("div.div_shouxian input.cpzl").val(),
                                        tare_weight: $("div.div_shouxian input.cppz").val(),
                                        actualDiameter: $("div.div_shouxian input.actualDiameter").val(),
                                        bmzl: $("div.div_shouxian .bmzl").val(),
                                        selfResult: $("div.div_shouxian .selfResult").val(),
                                        bhgx: JSON.stringify(bhgx),
                                        printAmount: 3,
                                        check: true
                                    },
                                    dataType: 'json',
                                    json: 'callback',
                                    success: function (res) {
                                        pass=1;
                                        if (res.success) {
                                            //console.log(data);
                                            loading_hide();
                                            $(".mengceng").hide();
                                            $("div.div_shouxian").hide();
                                            takeupsuccess(res.workOver);
                                            takeupSendLims(res.result._id, true);
                                            // 打印 热处理 收线 标签
                                            if (res.result) {
                                                takeupPrint("heatTakeup", res.result);
                                                takeupPrint("heatTakeup", res.result);
                                            }
                                        } else {
                                            console.log(res);
                                            loading_hide();
                                            $alert(res.message);
                                        }
                                    },
                                    error: function (error) {
                                        pass=1;
                                        console.log(error);
                                        loading_hide();
                                        $alert(error.responseText);
                                    }
                                });
                            }
                        }
                    ]
                });
            }
        }
    });

    function takeupsuccess(workOver) {
        if (workOver) {
            //收线完成，完工本机台计划
            $.confirm("该作业计划完成产量已达到计划产量，是否完工？", function () {
                loading_show("完工中...");
                $.ajax({
                    headers: {authorization: "Bearer " + localStorage.getItem("jwt")},
                    type: "post",
                    url: url + '/api/scheduleplan/heat/workover',
                    data: {
                        workoverType: "many",
                        line: $("section span.machine").html()
                    },
                    dataType: 'json',
                    json: 'callback',
                    success: function (result) {
                        if (result.success) {
                            loading_hide();
                            // $(".mengceng").hide();
                            // $("div.div_shouxian").hide();
                            $.alert('当前计划已完工', function () {
                                localStorage.setItem("heatMachine", $("section span.machine").html());
                                window.location.href = "heattakeup.html";
                            });
                        } else {
                            loading_hide();
                            $alert(result.message);
                        }
                    },
                    error: function (error) {
                        console.log(error);
                        loading_hide();
                        $alert(error.responseText);
                    }
                });
            }, function () {
                loading_hide();
                $alert("收线成功");
                localStorage.setItem("heatMachine", $("section span.machine").html());
                setTimeout(function () {
                    window.location.href = "heattakeup.html";
                }, 1200);
            })
        } else {
            //收线完工，刷新本机台计划
            $.ajax({
                headers: {authorization: "Bearer " + localStorage.getItem("jwt")},
                type: "post",
                url: url + '/api/scheduleplan/heat/takeup',
                data: {
                    line: $("section span.machine").html()
                },
                dataType: 'json',
                json: 'callback',
                success: function (res1) {
                    if (res1.success) {
                        loading_hide();
                        if (res1.isChange == "是") {
                            $alert("收线成功，计划已更新，请知悉");
                        } else {
                            $alert("收线成功");
                        }
                        loading_hide();
                        $alert("收线成功");
                        localStorage.setItem("heatMachine", $("section span.machine").html());
                        setTimeout(function () {
                            window.location.href = "heattakeup.html";
                        }, 1200);
                    } else {
                        console.log(res1);
                        loading_hide();
                        $alert(res1.message);
                    }
                },
                error: function (error) {
                    console.log(error);
                    loading_hide();
                    $alert(error.responseText);
                }
            });
        }
    }
    function takeupSendLims(virId, check) {
        $.ajax({
            headers: {authorization: "Bearer " + localStorage.getItem("jwt")},
            type: "post",
            url: url + '/app/heat/sendToLimsQuaFunc',
            dataType: 'json',
            data: {
                virId: virId,
                check: check
            },
            json: 'callback',
            cache: false,
            // timeout: 60000,
            success: function (res) {
                if (res.success) {
                    // var data = res.result;
                } else {

                }
            },
            error: function (error) {

            }
        });
    }

    // 点击 清楚 原料
    $(".bnt .clear").on("click", function () {
        var machine = $("section span.machine").html();
        var workplanNumber = $("section span.workplanNumber").html();
        var quantity = $("section div.material span.weight").html();
        var number = $("section div.material span.number").html();
        if (!workplanNumber || workplanNumber == "空") {
            return $alert("请先扫描机台号");
        }
        if (!machine || machine == "空") {
            $alert("请先扫描热处理机台");
        } else {
            $.confirm("当前用料剩余" + quantity + "，确认清除吗？", function () {
                loading_show("清除中...");
                $.ajax({
                    headers: {authorization: "Bearer " + localStorage.getItem("jwt")},
                    type: "post",
                    url: url + '/app/heat/clearMachinematerial',
                    dataType: 'json',
                    data: {
                        id: work_id,
                        batch: number,
                        machine: machine
                    },
                    json: 'callback',
                    cache: false,
                    timeout: 60000,
                    success: function (res) {
                        if (res.success) {
                            var data = res.result;
                            loading_hide();
                            $alert("清除成功");
                            localStorage.setItem("heatMachine", machine);
                            setTimeout(function () {
                                window.location.href = "heattakeup.html";
                            }, 1200);
                        } else {
                            console.log(res);
                            $alert(res.message);
                        }
                    },
                    error: function (error) {
                        //隐藏提示符 显示
                        loading_hide();

                        if (error.status == 0) {
                            $alert("请求超时，请再试一次！");
                        } else {
                            console.log(error);
                            $alert(error.responseText);
                        }
                    }
                });
            })
        }
    });

    //点击 查看计划
    $(".bnt .lookPlan").click(function () {
        var machine = $("section span.machine").html();
        var workplanNumber = $("section span.workplanNumber").html();
        if (!workplanNumber || workplanNumber == "空") {
            return $alert("请先扫描机台号");
        }
        if (!machine || machine == "空") {
            $alert("请先扫描热处理机台");
        } else {
            localStorage.setItem("heatMachine", machine);
            localStorage.setItem("heatType", "heattakeup");
            window.location.href = "heat_ckjh.html";
        }
    });


    //点击 完工
    $(".bnt .workover").click(function () {
        var machine = $("section span.machine").html();
        var workplanNumber = $("section span.workplanNumber").html();
        if (!workplanNumber || workplanNumber == "空") {
            return $alert("请先扫描机台号");
        }
        if (!machine || machine == "空") {
            $alert("请先扫描热处理机台");
        } else {
            var work_weight = $("section span.work_weight").html();
            var work_completeWeight = $("section span.work_completeWeight").html();
            // if (Number(work_completeWeight) < Number(accSub(work_weight, controlvalue_J))) return $alert("完成量小于计划量不可完工");
            $.confirm("确认完工吗？",function () {
                //调用 换班 接口
                loading_show("完工中...");
                //拉丝 机台 完工
                $.ajax({
                    headers: {authorization: "Bearer " + localStorage.getItem("jwt")},
                    type: "post",
                    url: url + '/api/scheduleplan/heat/workover',
                    data: {
                        line: machine
                    },
                    dataType: 'json',
                    json: 'callback',
                    success: function (res) {
                        if (res.success) {
                            var data = res.result;
                            console.log(data);
                            loading_hide();
                            $alert("完工成功");
                            setTimeout(function () {
                                window.location.href = "heattakeup.html";
                            }, 1200);
                        } else {
                            console.log(res);
                            loading_hide();
                            $alert(res.message);
                        }
                    },
                    error: function (error) {
                        console.log(error);
                        loading_hide();
                        $alert(error.responseText);
                    }
                });
            });
        }
    });


});
